<?php
	include_once('header.php');
	// 保存提交修改到数据库
	if ($_SERVER['REQUEST_METHOD']=='POST') {
		// 修改新评论是否发送通知邮件的选项
		if (@$_POST['email_new_comment']=='true') {
			$value_email_new_comment = 'true';
		} else {
			$value_email_new_comment = 'false';
		}
		$query_email_new_comment = "update `setting` set `value`='".$value_email_new_comment."' where `name`='email_new_comment'";
		$mysql_connection->query($query_email_new_comment);
		// 修改新评论是否发送通知邮件的选项 END
		$username_post = addslashes($_POST['username_text']);
		if ($_POST['password_hidden']==$_POST['password_text']) {
			$password_post = $_POST['password_text'];
		} else {
			$password_post = md5($_POST['password_text']);
		}
		$email_post = addslashes($_POST['email_text']);
		$query_edit_user = "update `root` set `username`='".$username_post."', `password`='".$password_post."', `Email`='".$email_post."'";
		$mysql_connection->query($query_edit_user);
	}
	// 保存提交修改到数据库 END

	// 取得登录名和密码
	$query_user = "select * from `root`";
	$result_user = $mysql_connection->query($query_user);
	$arr_user = $result_user->fetch_assoc();
	// 取得登录名和密码 END
	$setting = get_setting($mysql_connection);	// 更新设置信息到数组 $setting 中
?>

<div id="content_b"><table width="100%" border="0">
<tr><td colspan="2">修改用户名和密码</td></tr>
<form action="<?php echo $_SERVER['PHP_SELF'];?>?message_box=修改成功!" method="post">
	<tr><td>用户名：</td>
	<td><input type="text" class="input_text" value="<?php echo $arr_user['username'];?>" name="username_text" /></td></tr>
	<tr><td>密码：</td>
	<td><input type="password" class="input_text" value="<?php echo $arr_user['password'];?>" name="password_text" />
	<input type="hidden" value="<?php echo $arr_user['password'];?>" name="password_hidden" /></td></tr>
	<tr><td>电子信箱：</td>
	<td><input type="text" class="input_text" value="<?php echo $arr_user['Email'];?>" name="email_text" />
	<?php
		// 判断是否选上复选框
		if ($setting['email_new_comment']=='true') {
			$checkbox_email_new_comment = 'checked';
		} else {
			$checkbox_email_new_comment = '';
		}
		// 判断是否选上复选框
	?>
	&nbsp;<input type="checkbox" <?php echo $checkbox_email_new_comment;?> value="true" id="checkbox_edit_user" name="email_new_comment" />
	<label for="checkbox_edit_user">新评论发送到邮箱</label>
	</td></tr>
	<tr><td colspan="2"><input type="submit" value="保存修改" /></td></tr>
</form></table></div>
<?php include_once('footer.php');?>
